package thread;

public class SyncDemo3 {
    public static void main(String[] args) {
        new Thread(Foo::doSome).start();
        new Thread(Foo::doSome).start();
    }
}

class Foo{
    public static void doSome() {
        synchronized (Foo.class) {
            try {
                Thread t = Thread.currentThread();
                System.out.println(t.getName() + "正在执行方法");
                Thread.sleep(2000);
                System.out.println(t.getName() + "执行完毕");
            } catch (InterruptedException e) {
                throw new RuntimeException(e);
            }
        }
    }
}